﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;

namespace CarShop.Security.Contracts
{

    public class CarShopPrincipal : IPrincipal
    {
        private CarShopIdentity _identity;

        public CarShopPrincipal(CarShopIdentity identity)
        {
            _identity = identity;
        }

        public bool IsInRole(string role)
        {
            return _identity.Roles.Contains(role);
        }

        public IIdentity Identity
        {
            get { return _identity; }
            set { _identity = value as CarShopIdentity; }
        }

        public CarShopIdentity User
        {
            get { return _identity; }
        }
    }
}
